package cn.iocoder.yudao.module.jifenyuan.dal.mysql.sharecode;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.sharecode.ShareCodeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.jifenyuan.controller.app.sharecode.vo.*;

/**
 * 分享码对应的内容 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ShareCodeMapper extends BaseMapperX<ShareCodeDO> {

    default PageResult<ShareCodeDO> selectPage(AppShareCodePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShareCodeDO>()
                .eqIfPresent(ShareCodeDO::getShareCode, reqVO.getShareCode())
                .eqIfPresent(ShareCodeDO::getPayload, reqVO.getPayload())
                .betweenIfPresent(ShareCodeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShareCodeDO::getId));
    }

    default List<ShareCodeDO> selectList(AppShareCodeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShareCodeDO>()
                .eqIfPresent(ShareCodeDO::getShareCode, reqVO.getShareCode())
                .eqIfPresent(ShareCodeDO::getPayload, reqVO.getPayload())
                .betweenIfPresent(ShareCodeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShareCodeDO::getId));
    }

    default  ShareCodeDO selectByCode(String code){
        return selectOne(ShareCodeDO::getShareCode,code);
    }
}
